<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Simulateur du jeu d&#39;instructions d&#39;un processeur simple: Référence du fichier test_simul.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Généré par Doxygen 1.7.4 -->
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Simulateur du jeu d'instructions d'un processeur simple</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Page&#160;principale</span></a></li>
      <li><a href="annotated.html"><span>Structures&#160;de&#160;données</span></a></li>
      <li class="current"><a href="files.html"><span>Fichiers</span></a></li>
      <li><a href="dirs.html"><span>Répertoires</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Liste&#160;des&#160;fichiers</span></a></li>
      <li><a href="globals.html"><span>Portée&#160;globale</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('test__simul_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Fonctions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">Référence du fichier test_simul.c</div>  </div>
</div>
<div class="contents">

<p>Test du simulateur.  
<a href="#details">Plus de détails...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br/>
<code>#include &lt;stdlib.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="machine_8h_source.html">machine.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="debug_8h_source.html">debug.h</a>&quot;</code><br/>
</div><div class="textblock"><div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="closed.png"/> Graphe des dépendances par inclusion de test_simul.c:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><img src="test__simul_8c__incl.png" border="0" usemap="#test__simul_8c" alt=""/></div>
<map name="test__simul_8c" id="test__simul_8c">
<area shape="rect" id="node7" href="machine_8h.html" title="Description de la structure du processeur et de sa mémoire." alt="" coords="157,160,248,189"/><area shape="rect" id="node16" href="debug_8h.html" title="Fonctions de mise au point interactive." alt="" coords="240,83,315,112"/><area shape="rect" id="node11" href="instruction_8h.html" title="Description du jeu d&#39;instruction." alt="" coords="91,237,197,267"/></map>
</div>
</div>
<p><a href="test__simul_8c_source.html">Aller au code source de ce fichier.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Fonctions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__simul_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main</a> (int argc, char *argv[])</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Programme de test.  <a href="#a0ddf1224851353fc92bfbff6f499fa97"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="var-members"></a>
Variables</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="unionInstruction.html">Instruction</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__simul_8c.html#a53ae7c86b11d9a664628491ba41ca09d">text</a> []</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Segment de texte.  <a href="#a53ae7c86b11d9a664628491ba41ca09d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__simul_8c.html#ab06365569505a01a31c5b0da6227d724">textsize</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Taille utile du programme.  <a href="#ab06365569505a01a31c5b0da6227d724"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="instruction_8h.html#a0b5b15ce5f3a75b5dd0de6643cd3d958">Word</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__simul_8c.html#a0a1a7765b8d407ad9c19649d5a9dd699">data</a> []</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Premier exemple de segment de données initial.  <a href="#a0a1a7765b8d407ad9c19649d5a9dd699"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__simul_8c.html#ad74734ae58f284f6cc955dfecf50f0d0">dataend</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Fin de la zone de données utile.  <a href="#ad74734ae58f284f6cc955dfecf50f0d0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">const unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="test__simul_8c.html#aaf62fcfcec5bdcaf147f70c32398ab32">datasize</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Taille utile du segment de données.  <a href="#aaf62fcfcec5bdcaf147f70c32398ab32"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Description détaillée</h2>
<div class="textblock"><p>Test du simulateur. </p>

<p>Définition dans le fichier <a class="el" href="test__simul_8c_source.html">test_simul.c</a>.</p>
</div><hr/><h2>Documentation des fonctions</h2>
<a class="anchor" id="a0ddf1224851353fc92bfbff6f499fa97"></a><!-- doxytag: member="test_simul.c::main" ref="a0ddf1224851353fc92bfbff6f499fa97" args="(int argc, char *argv[])" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>argc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>argv</em>[]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Programme de test. </p>
<p>Options de la ligne de commande :</p>
<dl>
<dt>-d</dt>
<dd><p class="startdd">mode pas à pas (mise au point)</p>
<p class="enddd"></p>
</dd>
<dt>-f</dt>
<dd><p class="startdd">le programme est dans un fichier binaire ; le nom de ce fichier doit être fourni également en paramètre de la ligne de commande ; sans cette option, on exécute un programme de test prédéfini.</p>
<p class="enddd"></p>
</dd>
</dl>

<p>Définition à la ligne <a class="el" href="test__simul_8c_source.html#l00058">58</a> du fichier <a class="el" href="test__simul_8c_source.html">test_simul.c</a>.</p>

<p>Références <a class="el" href="prog__simple-bin_8c_source.html#l00010">data</a>, <a class="el" href="prog__simple_8c_source.html#l00038">dataend</a>, <a class="el" href="prog__simple-bin_8c_source.html#l00015">datasize</a>, <a class="el" href="machine_8h.html#aa69650bbdba0125402a22c4451755412">dump_memory()</a>, <a class="el" href="machine_8h.html#a9ac26e6f927cf2956823b4f9588d44df">load_program()</a>, <a class="el" href="machine_8h.html#a87cfff30238b966cfc3c0c416d7076e9">print_cpu()</a>, <a class="el" href="machine_8h.html#a549be6eaf631d871e9357513c748640d">print_data()</a>, <a class="el" href="machine_8h.html#aba3ce4987ef379073d9d3f31debf89e7">print_program()</a>, <a class="el" href="machine_8h.html#ac59b88844961c2479108151e24dd555a">read_program()</a>, <a class="el" href="machine_8h.html#ad0bfa0ce7434b963eea888d7b847ac3b">simul()</a>, et <a class="el" href="prog__simple-bin_8c_source.html#l00008">textsize</a>.</p>
<div class="fragment"><pre class="fragment">{
    <span class="keywordtype">bool</span> debug = <span class="keyword">false</span>;
    <span class="keywordtype">bool</span> binfile = <span class="keyword">false</span>;
    <span class="keywordtype">bool</span> no_exec = <span class="keyword">false</span>;
    <span class="keywordtype">char</span> *programfile = NULL;

    <span class="keywordflow">if</span> (argc &gt; 1) 
    {
        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> iarg = 1; iarg &lt; argc; ++iarg)
        {
            <span class="keywordflow">if</span> (argv[iarg][0] == <span class="charliteral">&#39;-&#39;</span>)
                <span class="keywordflow">switch</span> (argv[iarg][1])
                {
                <span class="keywordflow">case</span> <span class="charliteral">&#39;d&#39;</span>:
                    debug = <span class="keyword">true</span>;
                    <span class="keywordflow">break</span>;
                <span class="keywordflow">case</span> <span class="charliteral">&#39;b&#39;</span>: 
                    binfile = <span class="keyword">true</span>;
                    <span class="keywordflow">break</span>;
                 <span class="keywordflow">case</span> <span class="charliteral">&#39;l&#39;</span>: 
                    no_exec = <span class="keyword">true</span>;
                    <span class="keywordflow">break</span>;
                  <span class="keywordflow">case</span> <span class="charliteral">&#39;h&#39;</span>:
                    usage();
                    exit(EXIT_SUCCESS);
                <span class="keywordflow">default</span>:
                    fprintf(stderr, <span class="stringliteral">&quot;Unknown option: %s\n&quot;</span>, argv[iarg]);
                    usage();
                    exit(EXIT_FAILURE);
                }
            <span class="keywordflow">else</span> <span class="keywordflow">if</span> (binfile)
                programfile = argv[iarg];
            <span class="keywordflow">else</span> 
                fprintf(stderr, <span class="stringliteral">&quot;Trailing options ignored...\n&quot;</span>);
        }
    }

    <a class="code" href="structMachine.html" title="Structure générale de la machine.">Machine</a> mach;

    <span class="keywordflow">if</span> (!binfile) 
        <a class="code" href="machine_8h.html#a9ac26e6f927cf2956823b4f9588d44df" title="Chargement d&#39;un programme.">load_program</a>(&amp;mach, <a class="code" href="prog__simple-bin_8c.html#a09c9805cec0364d715497e6564245c48" title="Taille utile du programme.">textsize</a>, <a class="code" href="prog__simple-bin_8c.html#a53ae7c86b11d9a664628491ba41ca09d" title="Segment de texte.">text</a>, <a class="code" href="prog__simple-bin_8c.html#a5c7949e884a8b9b3d1ab9f070267bf33" title="Taille utile du segment de données.">datasize</a>, <a class="code" href="prog__simple-bin_8c.html#a0a1a7765b8d407ad9c19649d5a9dd699" title="Premier exemple de segment de données initial.">data</a>, <a class="code" href="prog__simple_8c.html#ad74734ae58f284f6cc955dfecf50f0d0" title="Fin de la zone de données utiles.">dataend</a>);
    <span class="keywordflow">else</span> 
        <a class="code" href="machine_8h.html#ac59b88844961c2479108151e24dd555a" title="Lecture d&#39;un programme depuis un fichier binaire.">read_program</a>(&amp;mach, programfile);   

    printf(<span class="stringliteral">&quot;\n*** Sauvegarde des programmes et données initiales en format binaire ***\n\n&quot;</span>);
    <a class="code" href="machine_8h.html#aa69650bbdba0125402a22c4451755412" title="Affichage du programme et des données.">dump_memory</a>(&amp;mach);

    printf(<span class="stringliteral">&quot;\n*** Machine state before execution ***\n&quot;</span>);
    <a class="code" href="machine_8h.html#aba3ce4987ef379073d9d3f31debf89e7" title="Affichage des instructions du programme.">print_program</a>(&amp;mach);
    <a class="code" href="machine_8h.html#a549be6eaf631d871e9357513c748640d" title="Affichage des données du programme.">print_data</a>(&amp;mach);
    <a class="code" href="machine_8h.html#a87cfff30238b966cfc3c0c416d7076e9" title="Affichage des registres du CPU.">print_cpu</a>(&amp;mach);

    <span class="keywordflow">if</span> (no_exec) 
        <span class="keywordflow">return</span> 0;

    printf(<span class="stringliteral">&quot;\n*** Execution trace ***\n\n&quot;</span>);
    <a class="code" href="machine_8h.html#ad0bfa0ce7434b963eea888d7b847ac3b" title="Simulation.">simul</a>(&amp;mach, debug);

    printf(<span class="stringliteral">&quot;\n*** Machine state after execution ***\n&quot;</span>);
    <a class="code" href="machine_8h.html#a87cfff30238b966cfc3c0c416d7076e9" title="Affichage des registres du CPU.">print_cpu</a>(&amp;mach);
    <a class="code" href="machine_8h.html#a549be6eaf631d871e9357513c748640d" title="Affichage des données du programme.">print_data</a>(&amp;mach);

    <span class="keywordflow">return</span> 0; 
}
</pre></div>
<p><div id="dynsection-1" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-1-trigger" src="closed.png"/> Voici le graphe d'appel pour cette fonction :</div>
<div id="dynsection-1-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-1-content" class="dyncontent" style="display:none;">
<div class="center"><img src="test__simul_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph.png" border="0" usemap="#test__simul_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph" alt=""/></div>
<map name="test__simul_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph" id="test__simul_8c_a0ddf1224851353fc92bfbff6f499fa97_cgraph">
<area shape="rect" id="node3" href="machine_8h.html#aa69650bbdba0125402a22c4451755412" title="Affichage du programme et des données." alt="" coords="109,5,232,35"/><area shape="rect" id="node5" href="machine_8h.html#a9ac26e6f927cf2956823b4f9588d44df" title="Chargement d&#39;un programme." alt="" coords="116,59,225,88"/><area shape="rect" id="node7" href="machine_8h.html#a87cfff30238b966cfc3c0c416d7076e9" title="Affichage des registres du CPU." alt="" coords="129,112,212,141"/><area shape="rect" id="node9" href="machine_8h.html#a549be6eaf631d871e9357513c748640d" title="Affichage des données du programme." alt="" coords="125,165,216,195"/><area shape="rect" id="node11" href="machine_8h.html#aba3ce4987ef379073d9d3f31debf89e7" title="Affichage des instructions du programme." alt="" coords="113,219,228,248"/><area shape="rect" id="node13" href="machine_8h.html#ac59b88844961c2479108151e24dd555a" title="Lecture d&#39;un programme depuis un fichier binaire." alt="" coords="113,272,228,301"/><area shape="rect" id="node15" href="machine_8h.html#ad0bfa0ce7434b963eea888d7b847ac3b" title="Simulation." alt="" coords="143,325,199,355"/></map>
</div>
</p>

</div>
</div>
<hr/><h2>Documentation des variables</h2>
<a class="anchor" id="a0a1a7765b8d407ad9c19649d5a9dd699"></a><!-- doxytag: member="test_simul.c::data" ref="a0a1a7765b8d407ad9c19649d5a9dd699" args="[]" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="instruction_8h.html#a0b5b15ce5f3a75b5dd0de6643cd3d958">Word</a> <a class="el" href="test__simul_8c.html#a0a1a7765b8d407ad9c19649d5a9dd699">data</a>[]</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Premier exemple de segment de données initial. </p>

<p>Définition à la ligne <a class="el" href="prog__simple-bin_8c_source.html#l00010">10</a> du fichier <a class="el" href="prog__simple-bin_8c_source.html">prog_simple-bin.c</a>.</p>

<p>Référencé par <a class="el" href="test__simul_8c_source.html#l00058">main()</a>.</p>

</div>
</div>
<a class="anchor" id="ad74734ae58f284f6cc955dfecf50f0d0"></a><!-- doxytag: member="test_simul.c::dataend" ref="ad74734ae58f284f6cc955dfecf50f0d0" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const unsigned <a class="el" href="test__simul_8c.html#ad74734ae58f284f6cc955dfecf50f0d0">dataend</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Fin de la zone de données utile. </p>

<p>Définition à la ligne <a class="el" href="prog__simple_8c_source.html#l00038">38</a> du fichier <a class="el" href="prog__simple_8c_source.html">prog_simple.c</a>.</p>

<p>Référencé par <a class="el" href="test__simul_8c_source.html#l00058">main()</a>.</p>

</div>
</div>
<a class="anchor" id="aaf62fcfcec5bdcaf147f70c32398ab32"></a><!-- doxytag: member="test_simul.c::datasize" ref="aaf62fcfcec5bdcaf147f70c32398ab32" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const unsigned <a class="el" href="test__simul_8c.html#aaf62fcfcec5bdcaf147f70c32398ab32">datasize</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Taille utile du segment de données. </p>

<p>Définition à la ligne <a class="el" href="prog__simple-bin_8c_source.html#l00015">15</a> du fichier <a class="el" href="prog__simple-bin_8c_source.html">prog_simple-bin.c</a>.</p>

<p>Référencé par <a class="el" href="test__simul_8c_source.html#l00058">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a53ae7c86b11d9a664628491ba41ca09d"></a><!-- doxytag: member="test_simul.c::text" ref="a53ae7c86b11d9a664628491ba41ca09d" args="[]" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="unionInstruction.html">Instruction</a> <a class="el" href="test__simul_8c.html#a53ae7c86b11d9a664628491ba41ca09d">text</a>[]</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Segment de texte. </p>
<p>Segment de texte.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>On voit ici l'intérêt de l'initialisation d'une union avec nommage explicite des champs. </dd></dl>

<p>Définition à la ligne <a class="el" href="prog__simple-bin_8c_source.html#l00001">1</a> du fichier <a class="el" href="prog__simple-bin_8c_source.html">prog_simple-bin.c</a>.</p>

</div>
</div>
<a class="anchor" id="ab06365569505a01a31c5b0da6227d724"></a><!-- doxytag: member="test_simul.c::textsize" ref="ab06365569505a01a31c5b0da6227d724" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const unsigned <a class="el" href="test__simul_8c.html#ab06365569505a01a31c5b0da6227d724">textsize</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Taille utile du programme. </p>

<p>Définition à la ligne <a class="el" href="prog__simple-bin_8c_source.html#l00008">8</a> du fichier <a class="el" href="prog__simple-bin_8c_source.html">prog_simple-bin.c</a>.</p>

<p>Référencé par <a class="el" href="test__simul_8c_source.html#l00058">main()</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="test__simul_8c.html">test_simul.c</a>      </li>
      <li class="footer">Généré le Tue May 31 2011 11:25:41 pour Simulateur du jeu d'instructions d'un processeur simple par&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>

</body>
</html>
